namespace Storage.Core
{
	internal class ReadByTypeQuery : IStorageQuery
	{
		public ReadByTypeQuery(string type)
		{
			Type = type;
		}

		public byte[] Serialize()
		{
			var serializer = new FastBinarySerializer(Type.Length + sizeof(byte));
			serializer.Write(StorageOpCodes.ReadByType);
			serializer.Write(Type);
			return serializer.Buffer;
		}

		public static ReadByTypeQuery Deserialize(IBinaryDeserializer ds)
		{
			return new ReadByTypeQuery(ds.ReadString());
		}

		public string Type { get; private set; }
	}
}